package com.tongcao.cn.contoller;

import com.tongcao.cn.annotation.SysLog;
import com.tongcao.cn.util.ImageUtil;
import com.tongcao.cn.util.QrCodeUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author:tongcao
 * @Date:2018/8/24 10:32
 * Description:
 */
@Controller
@RequestMapping("/code")
public class QrcodeController {


    /**
     * 测试将二维码输出到页面
     *
     * @param request
     * @param response
     */
    @SysLog("生成二维码")
    @RequestMapping("/test")
    public void testQRCode(HttpServletRequest request, HttpServletResponse response) {
        try {
            ServletOutputStream outputStream = response.getOutputStream();
            QrCodeUtil.generate("http://gateway.2dfire-pre.com/?paymentFee=1&app_key=3899b0927180a8798197c6862400b2fa&method=com.dfire.open.consumer.third.oauth&v=1.0&outTradeNo=1530757261414&sign=85E20863DE015126FED33D0C3ED9B1C1303210F8&entityId=00028788&lang=zh_CN&env=pre&timestamp=1530757261414&", 150, 150, ImageUtil.IMAGE_TYPE_JPG, outputStream);

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
